from selenium import webdriver
from selenium.webdriver.common.by import By
from options import options
from time import sleep

url = r'http://172.16.36.121/upload/'
deiver = webdriver.Chrome(options=options)
deiver.get(url)
deiver.maximize_window()
#登录
deiver.find_element(By.ID,'ls_username').clear()
deiver.find_element(By.ID,'ls_username').send_keys('admin')
deiver.find_element(By.ID,'ls_password').clear()
deiver.find_element(By.ID,'ls_password').send_keys('sa')
sleep(3)
deiver.find_element(By.XPATH,'//*[@id="lsform"]/div/div/table/tbody/tr[2]/td[3]/button/em').click()
sleep(3)


deiver.find_element(By.XPATH,'//*[@id="category_1"]/table/tbody/tr[1]/td[2]/h2/a').click()
deiver.find_element(By.ID,'newspecial').click() #
deiver.find_element(By.ID,'subject').send_keys('帖子02')
#嵌套页面
deiver.switch_to.frame('e_iframe')
deiver.find_element(By.XPATH,'/html/body').send_keys('铁汁铁汁')
# 跳出嵌套页面
deiver.switch_to.default_content()
deiver.find_element(By.ID,'postsubmit').click()
sleep(3)

#   退出
deiver.find_element(By.XPATH,'//*[@id="um"]/p[1]/a[7]').click()
sleep(3)
deiver.quit()


